#pragma once

#include <d3d11.h>
#include <d3dcompiler.h>
#include <wrl/client.h>
#include "ErrorLogger.h"

class VertexShader
{
public:
    // TODO: merge 2 initialization functions
    bool Initialize(Microsoft::WRL::ComPtr<ID3D11Device>& device, std::wstring& shaderpath, 
        D3D11_INPUT_ELEMENT_DESC * layoutDesc, UINT numElements);
    bool InitializeFromHLSL(Microsoft::WRL::ComPtr<ID3D11Device>& device, std::wstring& shaderpath, 
        D3D11_INPUT_ELEMENT_DESC * layoutDesc, UINT numElements);

    ID3D11VertexShader* GetShader();
    ID3D10Blob* GetBuffer();
    ID3D11InputLayout* GetInputLayout();

private:
    Microsoft::WRL::ComPtr<ID3D11VertexShader> shader;
    Microsoft::WRL::ComPtr<ID3D10Blob> shader_buffer;
    Microsoft::WRL::ComPtr<ID3D11InputLayout> input_layout;
};

class PixelShader
{
public:
    bool Initialize(Microsoft::WRL::ComPtr<ID3D11Device>& device, std::wstring shaderpath);
    bool InitializeFromHLSL(Microsoft::WRL::ComPtr<ID3D11Device>& device, std::wstring shaderpath);

    ID3D11PixelShader* GetShader();
    ID3D10Blob* GetBuffer();

private:
    Microsoft::WRL::ComPtr<ID3D11PixelShader> shader;
    Microsoft::WRL::ComPtr<ID3D10Blob> shader_buffer;
};


// load shader from hlsl file
HRESULT CreateShaderFromFile(const WCHAR * hlslFileName,
    LPCSTR entryPoint, LPCSTR shaderModel, ID3DBlob ** ppBlobOut);
